Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display wire-protocol when using --raw #520

Closed
wants to merge 2 commits into from

Conversation

ptpaterson
Copy link
Contributor

@ptpaterson ptpaterson commented Dec 12, 2024

Ticket(s): FE-6242

Problem

One might expect the wire-protocol when using --raw, but we currently query using the "simple" format, which loses information.

Solution

This PR updates the --raw option to force rendering the wire-protocol for successful query data. It assumes that rendering multiple formats are not desired.

Other changes

It's safe to make url option required, since we do provide it everywhere.

we don't provide a custom client argument anywhere, so I've removed that as an optional argument for the runQuery family of functions. It might cause a problem with the injected httpClient if we start passing in Client instances constructed elsewhere.

For v10 queries:

If --raw is specified, then the API Format is driven to be JSON, which means we will make queries with the "simple" format, in which the Fauna API sends a plain JSON response, and the Client reads it without any special decoding. We leverage that in this PR by providing a custom HTTPClient when --raw is specified. This client overrides the x-format header to be tagged. Since the client expects plain JSON, no special decoding is performed, and the wire protocol is forwarded on the caller, and we keep all the benefits of using the driver, e.g. error handling.

For v4 queries

No changes here, since querying with apiVersion 4 already returns the wire protocol. This works because --raw drives the output to be JSON, and the v4 driver provides toJSON implementation for Values and Expr to be the wire protocol.

Result

v10

query
image

shell
image

v4

...

Testing

WIP

@ptpaterson ptpaterson closed this Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant